﻿<!doctype html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>登录</title>
<link rel="stylesheet" type="text/css" href="css/styles.css">
</head>
<body>
<img src="img/bg.jpg" class="bg">
<div class="htmleaf-container">
	<div class="wrapper">
		<div class="container">
			<h1>图书管理系统系统</h1>
			<form class="form">
				<input type="text" id="username" placeholder="用户名" autocomplete="off">
				<input type="password" id="pw" placeholder="密码" onkeypress="EnterPress(event)" onkeydown="EnterPress()">
				<button type="button" id="login-button">登录</button>
			</form>
		</div>
		<ul class="bg-bubbles">
			<li></li>
			<li></li>
			<li></li>
			<li></li>
			<li></li>
			<li></li>
			<li></li>
			<li></li>
			<li></li>
			<li></li>
		</ul>
	</div>
</div>
<script src="js/jquery-1.9.1.min.js" type="text/javascript"></script>
<script>

	function EnterPress(e) { //传入 event
		var e = e || window.event;
		if (e.keyCode == 13) {
			document.getElementById("login-button").click();
		}
	}
$("#login-button").click(function () {
    $.ajax({
        type: "POST",
        url: "login.php",
        data: {
            username: $("#username").val(),
            pw:$("#pw").val()
        },
        dataType: 'JSON',
        cache: false, //不缓存此页面
        success: function (data) {
         if (data){
             location.href="index.php"
		 }
		 else{
		     alert('账号或者密码错误！');
		    location.reload()
		 }
        }
    });
})
</script>
</body>
</html>